#!/bin/sh

#######################ping telnet
if ping -c 3 www.baidu.com >/dev/null 2>&1;
then 

tping=1
else echo "ping is no"
exit
fi

a=`echo ""|telnet www.baidu.com 80 2>/dev/null|grep "Connected to www.baidu.com."|wc -l`
if [ $a -gt 0 ];then

ttelnet=1
else
echo "telnet is no"
exit
fi 

while [ $tping==1 ]&&[ $ttelnet==1 ]; do
#echo "ping and telnet www.baidu.com is all ok!"

   if [ ! -f /tmp/check_net.log ];then
       echo "This is ping and telnet for www.baidu.com web service scripts" > /tmp/check_net.log
   fi

echo "ping   www.baidu.com is SUCCESS" >> /tmp/check_net.log
echo "telnet www.baidu.com is SUCCESS" >> /tmp/check_net.log

    sleep 2
    done
